package com.itheima.tlias.mapper;

import com.itheima.tlias.pojo.dto.SelectDeptDTO;
import com.itheima.tlias.pojo.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {
    @Select("select id,name,update_time from dept order by update_time desc")
    List<SelectDeptDTO> selectAll();
    @Insert("insert into dept(name,create_time,update_time) values(#{d.name},#{d.createTime},#{d.updateTime})")
    int insertDept(@Param("d")Dept dept);
    @Delete("delete from dept where id = #{id}")
    int deleteById(@Param("id") Integer id);
    @Select("select * from dept where id = #{id}")
    SelectDeptDTO selectById(Integer id);

    int updateDept(SelectDeptDTO dept);
    @Select("select * from dept where name = #{name}")
    Dept selectDeptByName(String name);
}
